@extends('layouts.admin_master')
@section('content')
    <div class="alert alert-info alert-dismissible mb-2" role="alert">
        <h4 class="alert-heading mb-2">友情提示!</h4>
        <p class="mt-1">修改用户头像,点击下方图片位置,即可弹出图片选择框.</p>
        <p class="mt-1">头像修改成功后,会替换当前用户的头像显示.</p>
        <p class="mt-1">请注意选择头像图片类型!!!</p>
    </div>
    <div class="card col-12">
        <div class="card-body">
            <div class="row justify-content-center">
                <img src="{{auth('admin')->user()->icon?:asset('org/admin/icon/1.jpg')}}" alt="" style="cursor: pointer;border-radius: 50%;width: 150px; height: 150px;" id="icon" onclick="upImage(this)">
                <form action="{{route('adminuser.updateIcon')}}" method="post" id="changeIcon">
                    @csrf
                    <input type="hidden" name="icon" value="" >
                </form>
            </div>
            <div class="text-center">
                <small>点击图片修改头像</small>
            </div>
        </div>
    </div>
@endsection
@push('js')
    <script>
        layui.use('upload', function(){
            var upload = layui.upload;

            //执行实例
            var uploadInst = upload.render({
                elem: '#icon' //绑定元素
                ,url: '{{route('util.upload')}}' //上传接口
                ,done: function(res){
                    $('#box').attr('src',res.data.src);

                    $('input[name="icon"]').val(res.data.src);

                    $('#changeIcon').submit();
                }
                ,error: function(){
                    //请求异常回调
                }
            });
        });

    </script>
@endpush
